export default {
    /**
     * 获取变量的类型
     */
    typ: (function () {
        var type = {};
        var typeArr = ['String', 'Object', 'Number', 'Array', 'Undefined', 'Function', 'Null', 'Symbol'];
        for (var i = 0; i < typeArr.length; i++) {
            (function (name) {
                type['Is' + name] = function (obj) {
                    return Object.prototype.toString.call(obj) == '[object ' + name + ']';
                }
            })(typeArr[i]);
        }
        return type;
    })(),

    /**
     * 移除json字符串中的null或undefined，如果有嵌套对象遍历移除
     * @param jsonData
     */
    removeJsonNull: function (jsonData) {
        for(let i in jsonData){
            if (jsonData[i] == undefined || jsonData[i] == null) {
                delete  jsonData[i]
            } else if (this.typ.IsObject(jsonData[i])) {
                this.removeJsonNull(jsonData[i])
            }
        }
    },

    /**
     *
     * 是否重复点击
     * @param event
     * @returns {boolean}
     */
    isNotAgainClick:function (event) {
        if(!event.target.clickTimestamp){
            event.target.clickTimestamp = event.timestamp
            return true
        }else{
            if(event.timestamp - event.target.clickTimestamp > 300){
                event.target.clickTimestamp = event.timestamp
                return true
            }else{
                event.target.clickTimestamp = event.timestamp
                return false
            }
        }
    },

    /**
     * 事件状态的锁定延迟释放
     * @param event
     */
    lockEventDeferFree:function (event) {
        if(event.target.clickIsLock) {
            return true
        }
        event.target.clickIsLock = true
        setTimeout(()=>{
            event.target.clickIsLock = false
        },2000)
        return false

    }

}